﻿<UserControl x:Class="TanmiaGrp.GeneralLedger.WinApp.Views.AccountEditorView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:loc="clr-namespace:TanmiaGrp.GeneralLedger.WinApp"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mui="http://firstfloorsoftware.com/ModernUI"
             mc:Ignorable="d"
             d:DesignHeight="300"
             d:DesignWidth="300">
    <UserControl.Resources>
        <loc:NullToVisibilityConverter x:Key="nullConverter" />
    </UserControl.Resources>
    <Grid Style="{StaticResource ContentRoot}">
        <Grid.Resources>
            <Style TargetType="HeaderedContentControl">
                <Setter Property="Focusable"
                        Value="False" />
                <Setter Property="Margin"
                        Value="0,0,0,5" />

            </Style>
        </Grid.Resources>

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="20*" />
            <ColumnDefinition Width="80*" />
        </Grid.ColumnDefinitions>

        <StackPanel Grid.Column="0"
                    Orientation="Vertical"
                    Background="DarkGray">
            <Button Content="جديد"
                    Command="{Binding Path=NewCommand}" />
            <Button Content="حفظ"
                    Command="{Binding Path=SaveCommand}" />
            <Button Content="حفظ وجديد"
                    Command="{Binding Path=SaveAndNewCommand}" />

            <Button Content="حفظ واغلاق"
                    Command="{Binding Path=SaveAndCloseCommand}"
                    CommandParameter="{Binding RelativeSource={RelativeSource Self}}" />

            <Button Content="حذف"
                    Command="{Binding Path=DeleteCommand}"
                    CommandParameter="{Binding RelativeSource={RelativeSource Self}}" />

            <Button Content="الأول"
                    Command="{Binding Path=GoToForthEntityCommand}"
                    CommandParameter="{x:Static loc:NavigationMoveEnum.First}" />

            <Button Content="السابق"
                    Command="{Binding Path=GoToForthEntityCommand}"
                    CommandParameter="{x:Static loc:NavigationMoveEnum.Previous}" />

            <Button Content="التالي"
                    Command="{Binding Path=GoToBackEntityCommand}"
                    CommandParameter="{x:Static loc:NavigationMoveEnum.Next}" />

            <Button Content="الأخير"
                    Command="{Binding Path=GoToBackEntityCommand}"
                    CommandParameter="{x:Static loc:NavigationMoveEnum.Last}" />

            <Button Name="btnPopout"
                    Content="فتح في نافذة جديدة"
                    Click="OnPopout" />

            <Button Content="اغلاق"
                    Command="{Binding Path=CloseCommand}"
                    CommandParameter="{Binding RelativeSource={RelativeSource Self}}" />
        </StackPanel>

        <Grid Grid.Column="1">
            <ScrollViewer>
                <StackPanel Orientation="Vertical">
                    <HeaderedContentControl Header="رقم تعريف الحساب">
                        <TextBox Text="{Binding Path=Entity.AccountID}"
                                 IsReadOnly="True" />
                    </HeaderedContentControl>

                    <HeaderedContentControl Header="رقم الحساب">
                        <TextBox Text="{Binding Path=Entity.AccountNumber, ValidatesOnDataErrors=True, NotifyOnValidationError=True, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                    </HeaderedContentControl>

                    <HeaderedContentControl Header="اسم الحساب">
                        <TextBox Text="{Binding Path=Entity.AccountName, ValidatesOnDataErrors=True, NotifyOnSourceUpdated=True, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                    </HeaderedContentControl>

                    <HeaderedContentControl Header="مستوى الحساب">
                        <TextBox Text="{Binding Path=Entity.Level}" />
                    </HeaderedContentControl>

                    <HeaderedContentControl Header="طبيعة الحساب">
                        <CheckBox Content="رئيسي أو فرع"
                                  IsChecked="{Binding Path=Entity.IsTransactional, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                    </HeaderedContentControl>

                    <HeaderedContentControl Header="مفعل؟">
                        <CheckBox IsChecked="{Binding Path=Entity.IsEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                    </HeaderedContentControl>

                    <HeaderedContentControl Header="قبول الحركات الدائنة">
                        <CheckBox IsChecked="{Binding Path=Entity.IsDebitable, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                    </HeaderedContentControl>

                    <HeaderedContentControl Header="قبول الحركات المدينة">
                        <CheckBox IsChecked="{Binding Path=Entity.IsCreditable, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                    </HeaderedContentControl>

                    <HeaderedContentControl Header="قبول الشيكات">
                        <CheckBox IsChecked="{Binding Path=Entity.IsCheckable, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                    </HeaderedContentControl>

                    <HeaderedContentControl Header="قبول الحركات النقدية فقط">
                        <CheckBox IsChecked="{Binding Path=Entity.IsCashable, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                    </HeaderedContentControl>

                    <HeaderedContentControl Header="الحد الأعلى الدائن">
                        <TextBox Text="{Binding Path=Entity.MaxDebit, ValidatesOnDataErrors=True, NotifyOnValidationError=True, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                    </HeaderedContentControl>

                    <HeaderedContentControl Header="الحد الأعلى المدين">
                        <TextBox Text="{Binding Path=Entity.MaxCredit, ValidatesOnDataErrors=True, NotifyOnSourceUpdated=True, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                    </HeaderedContentControl>

                    <HeaderedContentControl Header="حساب ختامي؟">
                        <CheckBox IsChecked="{Binding Path=Entity.IsFinal, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                    </HeaderedContentControl>

                    <HeaderedContentControl Header="تاريخ إنشاء الحساب">
                        <DatePicker Text="{Binding Path=Entity.CreateDate, ValidatesOnDataErrors=True, NotifyOnValidationError=True, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                    </HeaderedContentControl>

                    <HeaderedContentControl Header="تاريخ آخر تعديل">
                        <TextBox Text="{Binding Path=Entity.LastUpdateDate}"
                                 IsReadOnly="True" />
                    </HeaderedContentControl>

                    <HeaderedContentControl Header="حساب الأب">
                        <ComboBox SelectedItem="{Binding Path=Entity.Parent, ValidatesOnDataErrors=True, NotifyOnSourceUpdated=True, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                    </HeaderedContentControl>

                    <HeaderedContentControl Header="المجموعات">
                        <ListBox ItemsSource="{Binding Path=Entity.AccountGroups, ValidatesOnDataErrors=True, NotifyOnSourceUpdated=True, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                    </HeaderedContentControl>

                    <HeaderedContentControl Header="مجموع المدين">
                        <TextBox Text="{Binding Path=Entity.TotalDebit}"
                                 IsReadOnly="True" />
                    </HeaderedContentControl>

                    <HeaderedContentControl Header="مجموع الدائن">
                        <TextBox Text="{Binding Path=Entity.TotalCredit}"
                                 IsReadOnly="True" />
                    </HeaderedContentControl>

                    <HeaderedContentControl Header="الرصيد">
                        <TextBox Text="{Binding Path=Entity.Balance}"
                                 IsReadOnly="True" />
                    </HeaderedContentControl>
                </StackPanel>
            </ScrollViewer>
            <Label Content="إذا أردت إنشاء مجموعة جديدة\r\nقم بالضغط على زر جديد أولا."
                   VerticalContentAlignment="Center"
                   HorizontalContentAlignment="Center"
                   Background="White"
                   Opacity=".7"
                   Visibility="{Binding Path=Entity, Converter={StaticResource nullConverter}}" />
        </Grid>
    </Grid>
</UserControl>
